//_____________________________________________________________________________
//
// Jinfeng Zhuang, 2024.W17
//_____________________________________________________________________________
//

#ifndef SWIP_UART_H
#define SWIP_UART_H

//_____________________________________________________________________________
// Configuration

#define CONFIG_RX_BUF_SIZE (1024)
#define CONFIG_TX_BUF_SIZE (1024)

//_____________________________________________________________________________
// Make the file independent

typedef unsigned int  U32;
typedef unsigned char U8;

struct ringbuf;

//_____________________________________________________________________________
// Command & Param List

enum
{
    UART_MODE_BLOCK = 0,
    UART_MODE_INTERRUPT,
    UART_MODE_DMA,
};

//_____________________________________________________________________________
// Handler

struct swip_uart
{
    U32            HWBASE;      // uart register base
    U32            INT;         // interrupt number
    U32            rx_remain;   // Bytes to receive
    U32            tx_remain;   // Bytes to send, full deplux supported
    U32            baudrate;    // default: 115200
    U32            mode;        // 0: Block, 1: Interrupt, 2: DMA
    struct ringbuf ring_tx;     // point to txbuf
    struct ringbuf ring_rx;     // point to rxbuf
    U8             txbuf[CONFIG_TX_BUF_SIZE];
    U8             rxbuf[CONFIG_RX_BUF_SIZE];
};

#endif
